# The example has a calendar widget and a label widget. The currently selected date is displayed in the label widget.



import sys
from PySide import QtGui, QtCore

class Window(QtGui.QWidget):
    def __init__(self):
        super(Window, self).__init__()

        self.setGeometry(200, 200, 270, 200)
        self.setWindowTitle("Calendar Widget")

        calendar = QtGui.QCalendarWidget(self)
        calendar.setGridVisible(True)
        calendar.move(20, 20)
        # If we select a date from the widget, a clicked[QtCore.QDate] signal is emitted. We connect this signal to
        # the user defined showDate() method.
        calendar.clicked[QtCore.QDate].connect(self.showDate)

        self.label = QtGui.QLabel(self)
        date = calendar.selectedDate()
        self.label.setText(date.toString())
        self.label.move(130, 180)

    def showDate(self, date):
        self.label.setText(date.toString())


if __name__ == "__main__":
    appObject = QtGui.QApplication(sys.argv)
    ex = Window()
    ex.show()
    sys.exit(appObject.exec_())
